<template>
  <div id="supervisionInformation" class="app-container">
    
    <el-form
        :inline="true"
        label-position="right"
        label-width="90px"
        class="demo-form-inline"
      >
        <el-form-item label="权利人姓名">
          <el-input style="width: 200px;" v-model="listQuery.applicantName" placeholder="" class="filter-item" />
        </el-form-item>
        <el-form-item label="复垦片块">
          <el-select clearable style="width: 200px;" v-model="listQuery.landId" placeholder="请选择">
            <el-option
              v-for="item in selectData"
              :key="item.landId"
              :label="item.landName"
              :value="item.landId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="开始时间">
          <el-date-picker
            value-format="yy-MM-dd HH:MM:ss"
            style="width: 200px;"
            v-model="listQuery.startTime"
            type="date"
            placeholder="开始时间"
            class="filter-item">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="截止时间">
          <el-date-picker
            value-format="yy-MM-dd HH:MM:ss"
            style="width: 200px;"
            v-model="listQuery.endTime"
            type="date"
            placeholder="截止时间"
            class="filter-item">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button @click="searchData" type="primary">查询</el-button>
        </el-form-item>
      </el-form>
    <el-table v-loading="listLoading" :data="list" border style="width: 100%">
          <el-table-column type="index" show-overflow-tooltip label="序号" width="80" align="center"></el-table-column>
          <el-table-column prop="applyNum" label="申请编号" align="center"></el-table-column>
          <el-table-column prop="applicantName" label="权利人" align="center"></el-table-column>
          <el-table-column prop="landName" label="外业核查地块" align="center"></el-table-column>
          <el-table-column prop="" label="核查位置" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.place?scope.row.place:'' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="" label="外业核查时间" align="center">
            <template slot-scope="scope">{{ scope.row.time?scope.row.time:'' }}</template>
            
          </el-table-column>
          <!-- <el-table-column prop="date" label="抽查结果"></el-table-column> -->

          <el-table-column label="操作" fixed="right">
            <!--  <template slot-scope="scope"> -->
            <template slot-scope="scope">
              <el-button size="mini" v-if="scope.row.time" type="text" @click="toSee(scope.row)">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
    <el-pagination style="margin-top:20px;text-align:center"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="listQuery.page"
      :page-sizes="[10, 15, 20, 25]"
      :page-size="listQuery.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import { supervisingInfo1 } from "@/api/jungongcehuiResultFuShen";

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger"
      };
      return statusMap[status];
    }
  },
  data() {
    return {
      // activeName: '1',
      list: null,
      listLoading: true,
      listQuery: {
        page: 1,
        size: 10,
        projectId:localStorage.getItem("projectId"),
        landId:'',
        applicantName: "",
        startTime:'',
        endTime:'',
      },
      total:0, //总数
       selectData:[], //选择框

    };
  },
  created() {
    this.getData1();
    this.getData1ForSelect()
  },
  methods: {
    //搜索
    searchData(){
      this.getData1()
    },
    //前往查看
    toSee(row){
      console.log(row)
      this.$router.push({
        path:'/jungongcehuiResultFuShen/supervisionInformation/detail',
        query:{
          id:row.landId,
          vcr:row.vcr?row.vcr:'',
          photo:row.photo?row.photo:'',
          coorDonate:row.coorDonate,
          landName:row.landName,
          time:row.time?row.time:'',
          place:row.place?row.place:''
        }
      })
      localStorage.setItem("zongheItem",JSON.stringify(row))
    },
    getData1ForSelect(){
      var data={
        page:1,
        size:99999,
        projectId:localStorage.getItem("projectId")
      }
      supervisingInfo1(data).then(res=>{
        console.log(res)
        this.selectData=res.data.rows
      })
    },
    getData1(){
      this.listLoading=true
      var data={}
      var objArr=this.listQuery
      for (var index in objArr) {
        if(objArr[index]!=''&&objArr[index]!=null){
          data[index]=objArr[index];
        }
      }
      supervisingInfo1(data).then(res=>{
        console.log(res)
        this.list=res.data.rows
        this.total=res.data.total
        this.listLoading=false
      }).catch(error=>{
        this.listLoading=false
      })
    },
    //改变每页显示条数
    handleSizeChange(e){
      console.log(e)
      this.listQuery.size=e
      this.getData1()
    },
    //改变页码
    handleCurrentChange(num){
      console.log(num)
      this.listQuery.page=num
      this.getData1()
    },
    handleClick(tab, event) {
      this.listQuery={
        page: 1,
        size: 10,
        projectId:localStorage.getItem("projectId"),
        landId:'',
        applicantName: "",
        startTime:'',
        endTime:'',
      }
      if(this.activeName=="1"){
        this.getData()
      }else{
        this.getData()
      }
    }
  }
};
</script>
<style lang="scss" scoped>
#supervisionInformation /deep/ .el-tabs__nav-wrap::after{
  height: 1px;
}
</style>
